#include "controls.h"
#include "myinputs.h"
#include "mydrawengine.h"
#include "vector2D.h"

const int MIDSCREENX = 512;
const int MIDSCREENY = 384;

float MousePointer::GetPosX()
{
	return pointerX;
}
float MousePointer::GetPosY()
{
	return pointerY;
}

Vector2D MousePointer::GetLocation()
{
	return m_PointerLocation;

}
Point2D MousePointer::GetPoint()
{
	m_Point.PlaceAt(m_PointerLocation);
	return m_Point;
}
void MousePointer::Initialise(float ScreenWidth, float ScreenHeight)
{
	pointerX=ScreenWidth/2;
	pointerY=ScreenHeight/2;
	m_PointerLocation.set(pointerX, pointerY);
}


void MousePointer::Update(float ScreenWidth, float ScreenHeight)
{

	MyInputs* pMyInputs = MyInputs::GetInstance();
	pMyInputs->SampleMouse();
	pointerX += pMyInputs->GetMouseDX();
	pointerY += pMyInputs->GetMouseDY();
	m_PointerLocation.set(pointerX, pointerY);

	// Ensuring pointer does not go off screen
	if(pointerX < 0)
		pointerX = 0;
	if(pointerX > ScreenWidth)
		pointerX = ScreenWidth;
	if(pointerY < 0)
		pointerY =0;
	if(pointerY > ScreenHeight)
		pointerY = ScreenHeight;

}
void MousePointer::Draw()
{
	MyInputs* pMyInputs = MyInputs::GetInstance();
	if(!pMyInputs->IfMouseLeftDown())
	{
		MyDrawEngine::GetInstance()->FillCircle(m_PointerLocation, 7, MyDrawEngine::BLUE);
	}
	else
	{
		MyDrawEngine::GetInstance()->FillCircle(m_PointerLocation, 7, MyDrawEngine::RED);
	}
}